home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8929 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Schildt <- Advanced Books
  5. Date: 6 Mar 96 14:12:08 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.826121528@rscernix>
  8. References: <8BA8405.02C70020DE.uuout@sourcebbs.com> <4gnt96INN205@keats.ugrad.cs.ubc.ca> <4h4q0v$24v@redstone.interpath.net> <danpop.825687663@rscernix> <4he6hb$ahn@solutions.solon.com>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4he6hb$ahn@solutions.solon.com> seebs@solutions.solon.com (Peter Seebach) writes:
  13.  
  14. >In article <danpop.825687663@rscernix>, Dan Pop <danpop@mail.cern.ch> wrote:
  15. >>Sorry, I can hardly believe that.  Here are two examples (originally
  16. >>posted by Lawrence Kirby) from page 53 of the _third_ edition of C-TCR:
  17. >
  18. >>    float f
  19. >>    printf("%f ", sizeof f);
  20. >>    printf("%d", sizeof(int));
  21. >>
  22. >>Both mistakes appeared in the second edition of the book, as well, and
  23. >>they are NOT typos.  Ideally, the author shouldn't be allowed to
  24. >>publish anything on a topic he is utterly unable to understand.
  25. >>Unfortunately, the market realities of today are far from ideal :-(
  26. >
  27. >I could consider the "%f" a typo; it is when I do it.
  28.  
  29. "%f" might be a typo (yet it was preserved between editions, so maybe
  30. it was not a typo :-) but the missing cast _cannot_ be a typo.
  31.  
  32. >The others are
  33. >stunning; the size_t vs int bug is subtle.
  34.  
  35. There is nothing subtle here, for someone who knows C (which rules Schildt
  36. out :-)  size_t is _guaranteed_ not to be defined as int, so using "%d"
  37. is plain idiotic.  I could understand a "%u", and qualify the author as
  38. mildly stupid :-)
  39.  
  40.  
  41. >The sizeof(ptr) bug is idiotic.
  42.  
  43. Every single bit as idiotic as "%d" for size_t.  Under special 
  44. circumstances, both give the "correct" results.  At least, sizeof(ptr)
  45. doesn't invoke undefined behaviour :-)
  46.  
  47. Dan
  48. --
  49. Dan Pop
  50. CERN, CN Division
  51. Email: danpop@mail.cern.ch 
  52. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  53.